package xyz.xtt.exchange.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;

import xyz.xtt.exchange.plus.IllegalSQLInnerInterceptor;
import xyz.xtt.exchange.plus.SqlInterceptor;

@Configuration
public class MybatisPlusConfig {

	@Bean
	public MybatisPlusInterceptor mybatisPlusInterceptor() {
		MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
		// 添加非法SQL拦截器
		interceptor.addInnerInterceptor(new IllegalSQLInnerInterceptor());
		// 添加自动分页插件
		interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
		return interceptor;
	}

	@Bean
	public SqlInterceptor addMybatisInterceptor() {
		return new SqlInterceptor();
	}
}